<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        div {
            margin-top: 30px;
            width: 150px;
            height: 150px;
            background-color: greenyellow;
            left: 50px;
        }
    </style>
</head>

<body>
    <div id="dv"></div>
    <input type="button" value="点击修改div颜色" id="btn" />
    <script>
        function my$(id) {
            return document.getElementById(id);
        }

        function ChangeStyle(bnObjet,dvObjet,json){
            this.bnObjet = bnObjet;
            this.dvObjet = dvObjet;
            this.json = json;
        }
        ChangeStyle.prototype.init = function (){
            var current = this;
            current.bnObjet.onclick = function (){
                   for (const key in current.json) {
                    current.dvObjet.style[key] = current.json[key];
                   }
            }
        }
        var json = {"width":"200px","height":"200px","background-color":"red"}    
        var changeStyle = new ChangeStyle(my$("btn"),my$("dv"),json)
        changeStyle.init();    

    </script>
</body>

</html>